package org.example.order.controller.front;

import com.alipay.api.AlipayApiException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.example.core.utils.R;
import org.example.order.service.OrderAliPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;


/**
 * @author 小杰_cc
 * @version 1.0
 */
@RestController
@RequestMapping("/oms/front/alipay")
public class OrderAliPayController {

    @Autowired
    private OrderAliPayService orderAliPayService;

    // 处理支付宝支付请求
    @GetMapping("/pay")
    private void pay(@RequestParam("orderSn") String orderSn, HttpServletResponse response) throws AlipayApiException, IOException {
        orderAliPayService.pay(orderSn,response);
    }

    @PostMapping("/notify")
    public R<?> payNotify(HttpServletRequest request) throws AlipayApiException {
        return orderAliPayService.payNotify(request);
    }
}